﻿<UserControl 
  x:Class="Vision.VisionWorkshop.Controls.TypeBrowserControl"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Grid>

        <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <Border Grid.Row="0" BorderBrush="Gray">
            <StackPanel Orientation="Horizontal">
                <TextBox  Margin="2" Name="SelectedType" HorizontalAlignment="Stretch"/>
                <Button   Margin="2" Name="RefreshButton" Content="Refresh" Click="RefreshButton_Click" HorizontalAlignment="Right"/>
            </StackPanel>            
        </Border>

        <ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Visible" Margin="0" MinHeight="100">
            <TreeView 
                Name="myTreeViewItem" 
                ItemsSource="{Binding FirstGeneration}" 
                SelectedValuePath="MemberName"
                HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                BorderThickness="0"
                SelectedItemChanged="SelectedItemChangedHandler"
                >
                <TreeView.ItemContainerStyle>
                    <Style TargetType="{x:Type TreeViewItem}">
                        <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                        <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                        <Setter Property="FontWeight" Value="Normal" />
                        <Style.Triggers>
                            <Trigger Property="IsSelected" Value="True">
                                <Setter Property="FontWeight" Value="Bold" />
                            </Trigger>
                        </Style.Triggers>
                    </Style>
                </TreeView.ItemContainerStyle>

                <TreeView.ItemTemplate >
                    <HierarchicalDataTemplate ItemsSource="{Binding Children}" >
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding MemberName}" />
                            <TextBlock Text=" [" />
                            <TextBlock Text="{Binding TypeName}" />
                            <TextBlock Text="]" />
                        </StackPanel>
                    </HierarchicalDataTemplate>
                </TreeView.ItemTemplate>
            </TreeView>
        </ScrollViewer>
    </Grid>
</UserControl>
